#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define MAXN 100

typedef struct SNode* PtrToSNode;
typedef struct {
    int N;
    char from;
    char using;
    char to;
} ElementType;
struct SNode {
    ElementType* Data;
    int Top;
    int Maxsize;
};
typedef PtrToSNode Stack;
Stack CreateStack ( int Maxsize ) {
    Stack S = (Stack)malloc(sizeof(struct SNode));
    S->Data = (ElementType*)malloc(Maxsize*sizeof(ElementType));
    S->Top = -1;
    S->Maxsize = Maxsize;
    return S;
}
bool StackEmpty ( Stack S ) {
    return ( S->Top == -1 );
}
ElementType Pop ( Stack S ) {
    if ( StackEmpty(S) ) {
        printf("Stack Empty\n");
        exit(-1);
    }
    return ( S->Data[(S->Top)--] );
}
bool StackFull ( Stack S ) {
    return ( ( S->Top + 1 ) == S->Maxsize );
}
void Push ( Stack S, ElementType X ) {
    if ( StackFull(S) ) {
        printf("Stack Full\n");
        exit(-2);
    }
    S->Data[++(S->Top)] = X;
}
void Hanoi ( int N, char from, char using, char to ) {
    Stack S = CreateStack(MAXN);
    ElementType P,ToPush;
    P.from = from;
    P.using = using;
    P.to = to;
    P.N = N;
    Push(S,P);
    while ( !StackEmpty(S) ) {
        P = Pop(S);
        if ( P.N == 1 ) {
            printf("%c -> %c\n",P.from,P.to);
        } else {
            ToPush.N = P.N - 1;
            ToPush.from = P.using;
            ToPush.using = P.from;
            ToPush.to = P.to;
            Push(S,ToPush);
            ToPush.N = 1;
            ToPush.from = P.from;
            ToPush.using = P.using;
            ToPush.to = P.to;
            Push(S,ToPush);
            ToPush.N = P.N - 1;
            ToPush.from = P.from;
            ToPush.using = P.to;
            ToPush.to = P.using;
            Push(S,ToPush);
        }
    }
    free(S);
}

int main () {
    int N;
    scanf("%d",&N);
    Hanoi(N,'A','B','C');
    return 0;
}